<div>
  <!-- 面包屑导航 -->
  <el-breadcrumb separator-class="el-icon-arrow-right" class="bread" width="300">
    <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>权限管理</el-breadcrumb-item>
    <el-breadcrumb-item>角色列表</el-breadcrumb-item>
  </el-breadcrumb>
  <!-- 角色表格 -->
  <el-table :data="rolesList">
    <el-table-column type="expand">
      <template slot-scope="scope">
        <!-- span放在之后问题的说明：
            因为v-for的优先级要高于v-if。所以当没有数据时候一个结构都没渲染出来
            自然而然的就没有v-if可以判断
            所以span中的else单独出现 导致走不到span
         -->
        <span v-if="scope.row.children.length === 0">暂无权限</span>
        <el-row v-else v-for="level1 in scope.row.children" :key="scope.row.children.id">
          <el-col :span="6">
            <el-tag closable :disable-transitions="false" @close="delRights(scope.row, level1.id)">
              {{ level1.authName }}
            </el-tag>
            <i class="el-icon-arrow-right"></i>
          </el-col>
          <el-col :span="18">
            <el-row class="level2" v-for="level2 in level1.children" :key="level2.id">
              <el-col :span="8">
                <el-tag type="success" closable :disable-transitions="false" @close="delRights(scope.row, level2.id)">
                  {{ level2.authName }}
                </el-tag>
                <i class="el-icon-arrow-right"></i>
              </el-col>
              <el-col :span="16">
                <el-tag class="level3" type="warning" v-for="(level3, index) in level2.children" :key="level3.id"
                  closable :disable-transitions="false" @close="delRights(scope.row, level3.id)">
                  {{ level3.authName }}
                </el-tag>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </template>
    </el-table-column>
    <el-table-column type="index" :index="indexMethod">
    </el-table-column>
    <el-table-column prop="roleName" label="角色名称" width="180">
    </el-table-column>
    <el-table-column prop="roleDesc" label="描述" width="180">
    </el-table-column>
    <el-table-column label="操作" width="260">
      <template slot-scope="scope">
        <!-- 编辑 -->
        <el-button type="primary" icon="el-icon-edit" size="mini" :plain="true"></el-button>
        <!-- 删除 -->
        <el-button type="danger" icon="el-icon-delete" size="mini" :plain="true"></el-button>
        <!-- 分配权限 -->
        <el-button @click="showRolesRightTree(scope.row)" type="success" icon="el-icon-check" size="mini" :plain="true">分配权限</el-button>
      </template>
    </el-table-column>
  </el-table>

  <!-- 角色授权对话框 -->
  <el-dialog title="角色授权" :visible.sync="isShowRolesRightTree">
    <!-- 角色授权树  --> 
    <el-tree ref="rightsTree" :default-expand-all="true" :data="rolesRightsTree" show-checkbox node-key="id"
      :props="defaultProps">
    </el-tree>
    <div slot="footer" class="dialog-footer">
      <el-button @click="isShowRolesRightTree = false">取 消</el-button>
      <el-button type="primary" @click="updateRolesRights">确 定</el-button>
    </div>
  </el-dialog>
</div>